Draft
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #6 +/- ##
=======================================
Coverage 76.89% 76.89%
=======================================
Files 109 109
Lines 10133 10133
Branches 1764 1764
=======================================
Hits 7792 7792
Misses 2322 2322
Partials 19 19 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
This PR adds two new modules for authoring Player-UI content in Kotlin:
language/dsl/kotlin- A Kotlin DSL library for building Player-UI flows and assets programmaticallylanguage/generators/kotlin- A code generator that produces Kotlin DSL builders from XLR JSON schemasMotivation
Kotlin/Java developers currently lack a type-safe way to construct Player-UI content. This DSL provides compile-time validation and IDE support when building flows, views, and assets.
1. Generate Asset Builders
Run the generator CLI against your XLR JSON definitions:
Or point at a directory to process all XLR files at once:
This produces one Kotlin file per asset type (e.g.
TextBuilder.kt,ActionBuilder.kt).2. Generate Schema Bindings
Generate type-safe bindings from a Player-UI schema JSON:
Given this schema:
{ "ROOT": { "user": { "type": "UserType" }, "items": { "type": "ItemType", "isArray": true } }, "UserType": { "firstName": { "type": "StringType" }, "email": { "type": "StringType" }, "age": { "type": "NumberType" } }, "ItemType": { "id": { "type": "StringType" }, "label": { "type": "StringType" } } }The generator produces:
Array types automatically use
_current_placeholders in their paths.Usage
Building Assets
Every generated asset type provides two equivalent patterns: a DSL lambda (idiomatic Kotlin) and a fluent chaining API.
DSL Pattern (Lambda)
Fluent Pattern (Chaining)
Both patterns produce identical output. Use whichever reads better for your use case, the DSL pattern works well for nested structures, while the fluent pattern is convenient for simple or programmatic construction.
Tagged Values: Bindings and Expressions
Bindings and expressions are the two types of dynamic values in Player-UI.
Use bindings and expressions anywhere a static value can go:
Standard Expression Library
The DSL provides built-in functions for common operations:
Building Complete Flows
A flow combines views, data, navigation, and optionally a schema into a complete Player-UI content structure.
Navigation
The navigation DSL supports VIEW, ACTION, and END states:
navigation { flow("FLOW_1") { startState = "VIEW_step1" // VIEW states reference a view by index view("VIEW_step1", ref = "my-flow-views-0") { on("next", "ACTION_validate") on("cancel", "END_Cancelled") } // ACTION states run an expression, then transition based on result action("ACTION_validate", expression<Unit>("validate()")) { on("success", "VIEW_step2") on("error", "VIEW_step1") } view("VIEW_step2", ref = "my-flow-views-1") { on("submit", "END_Done") on("back", "VIEW_step1") } // END states terminate the flow with an outcome end("END_Done", outcome = "done") end("END_Cancelled", outcome = "cancelled") } }Templates
Templates generate dynamic or static repeated content from data arrays:
Switches
Switches provide conditional content selection, useful for i18n, A/B testing, or feature flags: